package ro.myApp.security.client;

import org.hibernate.validator.Email;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;

import ro.myApp.client.BaseView;
import ro.myApp.security.dto.UserForgotPasswordMessage;
import ro.myApp.security.dto.UserForgotUsernameMessage;

@Name("reminder")
@BypassInterceptors
@Scope(ScopeType.PAGE)
public class Reminder extends BaseView {

	/**
	 * 
	 */
	private static final long serialVersionUID = -759260521082109864L;
	
	private String username;
	
	private String email;
	
	private int which = 0;//0 - both hidden, 1 - first show, 2 - second show
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	
	@Email
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
	public void forgotPassword (){
		sendMessage(new UserForgotPasswordMessage(username));
	}
	
	public void forgotUsername (){
		sendMessage(new UserForgotUsernameMessage(email));
	}
	
	public boolean isShowForgotPassword (){
		return 1==which;
	}
	public boolean isShowForgotUsername (){
		return 2==which;
	}
	
	public void toggleForgotPassword (){
		if (isShowForgotPassword())
			which=0;//show none;
		else
			which=1;//show forgot pass
	}
	public void toggleForgotUsername (){
		if (isShowForgotUsername())
			which=0;//show none;
		else
			which=2;//show forgot pass		
	}

}
